package com.meida.student.app.scholartyrant.handler;


import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.PageInterceptor;
import com.meida.common.mybatis.model.PageParams;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.msg.client.entity.MsgContent;
import com.meida.msg.client.entity.MsgReceive;
import com.meida.msg.client.entity.MsgType;
import org.springframework.stereotype.Component;

/**
 * 学霸消息中心分页扩展
 */
@Component("SMsgPageListHandler")
public class SMsgPageListHandler implements PageInterceptor<MsgReceive> {


    @Override
    public void prepare(CriteriaQuery<MsgReceive> cq, PageParams pageParams, EntityMap params) {
        cq.clear();
        cq.select(MsgReceive.class, "msgUserId", "msgId", "readState", "createTime");
        cq.select(MsgContent.class, "msgTitle", "msgDescribe");
        cq.eq(MsgReceive.class, "readState");
        cq.eq(MsgType.class, "typeCode");
        cq.createJoin(MsgType.class).setMainAlias("content").setJoinAlias("type").setJoinField("msgTypeId");
    }
}
